package com.hmdp.controller;


import com.hmdp.dto.Result;
import com.hmdp.service.IFollowService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author
 * @since 2021-12-22
 */
@Slf4j
@RestController
@RequestMapping("/follow")
public class FollowController {
    @Autowired
    private IFollowService followService;

    /**
     * 关注用户
     * @param id
     * @param isFollow
     * @return
     */
    @PutMapping("/{id}/{isFollow}")
    public Result FocusOnUser(@PathVariable("id")Long id, @PathVariable("isFollow")Boolean isFollow) {
        log.info("关注用户:{},{}",id,isFollow);
        return followService.FocusOnUser(id,isFollow);
    }

    /**
     * 查看是否关注用户
     * @param followUserId
     * @return
     */
    @GetMapping("/or/not/{id}")
    public Result isFocusONUser(@PathVariable("id")Long followUserId) {
        log.info("查看是否关注用户:{}",followUserId);
        return followService.isFocusONUser(followUserId);
    }

    /**
     * 查看共同关注好友
     * @param followUserId
     * @return
     */
    @GetMapping("/common/{id}")
    public Result commonFollow(@PathVariable("id")Long followUserId) {
        log.info("查看共同关注好友:{}",followUserId);
        return followService.commonFollow(followUserId);
    }


}
